import 'package:json_annotation/json_annotation.dart';

import 'home_info.dart';

part 'store_data.g.dart';

@JsonSerializable()
class StoreData extends Object {
  @JsonKey(name: 'last_time')
  String lastTime;

  @JsonKey(name: 'sales_region')
  List<SalesRegion> salesRegion;

  @JsonKey(name: 'new_shop')
  NewShop newShop;

  @JsonKey(name: 'all_shop_count')
  String allShopCount;

  @JsonKey(name: 'month_cover')
  MonthCover monthCover;

  @JsonKey(name: 'shop_data')
  List<ShopData> shopData;

  @JsonKey(name: 'shop_data_max')
  String shopDataMax;

  @JsonKey(name: 'shop_average')
  String shopAverage;

  @JsonKey(name: 'shop_unit')
  List<ShopUnit> shopUnit;

  @JsonKey(name: 'shop_unit_max')
  String shopUnitMax;

  @JsonKey(name: 'order_rinking')
  List<OrderRinking> orderRinking;

  StoreData(
    this.lastTime,
    this.salesRegion,
    this.newShop,
    this.allShopCount,
    this.monthCover,
    this.shopData,
    this.shopDataMax,
    this.shopAverage,
    this.shopUnit,
    this.shopUnitMax,
    this.orderRinking,
  );

  factory StoreData.fromJson(Map<String, dynamic> srcJson) =>
      _$StoreDataFromJson(srcJson);

  Map<String, dynamic> toJson() => _$StoreDataToJson(this);
}

@JsonSerializable()
class NewShop extends Object {
  @JsonKey(name: 'shop_count')
  String shopCount;

  @JsonKey(name: 'shop_details')
  List<ShopDetails> shopDetails;

  NewShop(
    this.shopCount,
    this.shopDetails,
  );

  factory NewShop.fromJson(Map<String, dynamic> srcJson) =>
      _$NewShopFromJson(srcJson);

  Map<String, dynamic> toJson() => _$NewShopToJson(this);
}

@JsonSerializable()
class ShopDetails extends Object {
  @JsonKey(name: 'reg_times')
  String regTimes;

  @JsonKey(name: 'shop_name')
  String shopName;

  @JsonKey(name: 'address')
  String address;

  ShopDetails(
    this.regTimes,
    this.shopName,
    this.address,
  );

  factory ShopDetails.fromJson(Map<String, dynamic> srcJson) =>
      _$ShopDetailsFromJson(srcJson);

  Map<String, dynamic> toJson() => _$ShopDetailsToJson(this);
}

@JsonSerializable()
class MonthCover extends Object {
  @JsonKey(name: 'active_customer')
  String activeCustomer;

  @JsonKey(name: 'login_count')
  String loginCount;

  @JsonKey(name: 'login_rate')
  String loginRate;

  @JsonKey(name: 'pre_login_rate')
  String preLoginRate;

  @JsonKey(name: 'active_count')
  String activeCount;

  @JsonKey(name: 'active_rate')
  String activeRate;

  @JsonKey(name: 'pre_active_rate')
  String preActiveRate;

  MonthCover(
    this.activeCustomer,
    this.loginCount,
    this.loginRate,
    this.preLoginRate,
    this.activeCount,
    this.activeRate,
    this.preActiveRate,
  );

  factory MonthCover.fromJson(Map<String, dynamic> srcJson) =>
      _$MonthCoverFromJson(srcJson);

  Map<String, dynamic> toJson() => _$MonthCoverToJson(this);
}

@JsonSerializable()
class ShopData extends Object {
  @JsonKey(name: 'order_num')
  String orderNum;

  @JsonKey(name: 'months')
  String months;

  @JsonKey(name: 'active_num')
  String activeNum;

  @JsonKey(name: 'active_rate')
  String activeRate;

  ShopData(
    this.orderNum,
    this.months,
    this.activeNum,
    this.activeRate,
  );

  factory ShopData.fromJson(Map<String, dynamic> srcJson) =>
      _$ShopDataFromJson(srcJson);

  Map<String, dynamic> toJson() => _$ShopDataToJson(this);
}

@JsonSerializable()
class ShopUnit extends Object {
  @JsonKey(name: 'title')
  String title;

  @JsonKey(name: 'month_count')
  String monthCount;

  @JsonKey(name: 'pre_count')
  String preCount;

  ShopUnit(
    this.title,
    this.monthCount,
    this.preCount,
  );

  factory ShopUnit.fromJson(Map<String, dynamic> srcJson) =>
      _$ShopUnitFromJson(srcJson);

  Map<String, dynamic> toJson() => _$ShopUnitToJson(this);
}

@JsonSerializable()
class OrderRinking extends Object {
  @JsonKey(name: 'address')
  String address;

  @JsonKey(name: 'shop_name')
  String shopName;

  @JsonKey(name: 'amounts')
  String amounts;

  OrderRinking(
    this.address,
    this.shopName,
    this.amounts,
  );

  factory OrderRinking.fromJson(Map<String, dynamic> srcJson) =>
      _$OrderRinkingFromJson(srcJson);

  Map<String, dynamic> toJson() => _$OrderRinkingToJson(this);
}
